<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* \转义字符 遇到一些特殊的字符需要处理,可以在前面加上转义字符 */
        var str = "https://www.baidu.com"
        var str2 = "http://www.baidu.com"
        var reg = /(http|https):\/\/[w]{3}\.baidu\.com/
        console.log(reg.test(str));
        console.log(reg.test(str2));
    </script>
</body>
</html>